<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>

<script>
	function getByClass(oParent,sClass)
	{
			var results =[];
			var eEle = oParent.getElementsByTagName('*');

			for(var i=0; i < eEle.length; i++)
			{
					if(eEle[i].className == sClass)
					{
							results.push(eEle[i]);
					}
			}
			return results;
		
	}
	
window.onload=function()
{
		var oUl = document.getElementById('ul1');
	/*
		var oLi = oUl.getElementsByClassName('box');
	

	for(var i=0 ; i< oLi.length; i++)
		{
				oLi[i].style.background = 'red';
		}
		*/
	var test = getByClass(oUl,'box')

	for(var i=0 ; i< test.length; i++)
	{
			test[i].style.background = 'red';
	}
		
};
</script>
</head>

<body>
<ul id="ul1">
	<li class="box"></li>
	<li class="box"></li>
	<li></li>
	<li class="box"></li>
</ul>
</body>
</html>
